package com.itheima.web.manager;

import com.itheima.domain.db.AnalysisByYear;
import com.itheima.domain.db.AnalysisItmes;
import com.itheima.service.db.AnalysisByDayService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AnalysisManager {

    @DubboReference
    AnalysisByDayService analysisByDayService;

    public ResponseEntity findSummary() {
        return ResponseEntity.ok(analysisByDayService.findSummary());
    }

    public AnalysisByYear findSummaryView(Long startDate, Long endDate, String type) {
        List<List<AnalysisItmes>> list = analysisByDayService.findSummaryView(startDate, endDate, type);

        AnalysisByYear analysisByYear = new AnalysisByYear();

        analysisByYear.setThisYear(list.get(0));
        analysisByYear.setLastYear(list.get(1));

        return analysisByYear;
    }
}